package waggle.client.forms;

import com.google.gwt.user.client.ui.TextBox;

/**
 * An email {@link FormInput}.
 * 
 */
public class EmailFormInput extends FormInput {

  /**
   * Constructs a new email form input,
   * 
   * @param inputTitle the email form title
   * 
   */
  public EmailFormInput(String inputTitle, boolean validate) {
    super(inputTitle, new TextBox(), validate);
  }

  @Override
  public void clear() {
    ((TextBox) widget).setText("");
  }

  @Override
  public String getInputValue() {
    return ((TextBox) widget).getText();
  }

  @Override
  public String validate() {
    if (validateInput) {
      return isValidEmailFormat(getInputValue()) ? null : "";
    }
    return null;
  }

}
